#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		int n; cin >> n;
		string s; cin >> s;
		int a = 0, b = 0;
		for (int i = 0; i < s.size(); i++) {
			if (a == 0 && s[i] == 'D') a++;
			if (a == 1 && s[i] == 'F') a++;
			if (a == 2 && s[i] == 'S') a++;
			if (b == 0 && s[i] == 'd') b++;
			if (b == 1 && s[i] == 'f') b++;
			if (b == 2 && s[i] == 's') b++;
		}
		cout << (a == 3) << " " << (b == 3) << endl;
	}
	return 0;
}